home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
totsrc11.zip
/
TOTINPUT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-04
|
32KB
|
1,252 lines
{ Copyright 1991 TechnoJock Software, Inc. }
{ All Rights Reserved }
{ Restricted by License }
{ Build # 1.10a }
Unit totINPUT;
{$I TOTFLAGS.INC}
{
Development Notes:
1.00a 3/28/91 Add Mouse method SetForceOff to stop Toolkit
making the mouse visible;
1.00b 5/23/91 Corrected ret codes with Mouse method 1
1.00c 6/02/91 Changed Shiftpressed check for XT's
1.00d 7/23/91 Replaced CRT Readkey with interrupt to better
support extended clone keyboards.
1.00e 8/17/91 Allowed keyboard stuffing in the idle hook.
1.00f 2/03/92 Added SetSlowdelay method
1.00g 3/09/92 Added support for vSetLeft
1.10 12/15/92 DPMI Update
1.10a 02/29/93 Corrected extended keyboard recognition problem
1.10b 05/03/93 Improved Double-Click reponse on fast systems --
thanks Arnold!
Added MouseOBJ.WaitForRelease method
}
INTERFACE
{$IFDEF DPMI}
uses DOS,CRT,WINAPI;
{$ELSE}
uses DOS,CRT;
{$ENDIF}
Const
StuffBufferSize = 30;
Type
InputIdleProc = procedure;
InputPressedProc = procedure(var W:word);
CharProc = procedure(W:word);
CaseFunc = function(Ch:char):char;
CharSet = set of char;
pAlphabetOBJ = ^AlphabetOBJ;
AlphabetOBJ = object
vUpper: CharSet;
vLower: CharSet;
vPunctuation: CharSet;
vUpCaseFunc: CaseFunc;
vLoCaseFunc: CaseFunc;
{methods...}
constructor Init;
procedure AssignUpCaseFunc(Func:caseFunc);
procedure AssignLoCaseFunc(Func:caseFunc);
procedure SetUpper(Letters:CharSet);
procedure SetLower(Letters:CharSet);
procedure SetPunctuation(Letters:CharSet);
function IsUpper(K:word): boolean;
function IsLower(K:word): boolean;
function IsLetter(K:word): boolean;
function IsPunctuation(K:word): boolean;
function GetUpCase(Ch:char):char;
function GetLoCase(Ch:char):char;
destructor Done;
end; {AlphabetOBJ}
pMouseOBJ = ^MouseOBJ;
MouseOBJ = object
vInstalled: boolean; {is the system equipped with a mouse}
vButtons: byte; {how many buttons on mouse}
vLeftHanded: boolean; {is right button Enter?}
vIntr: integer; {mouse interrupt number}
vVisible: boolean; {is mouse cursor visible?}
vForceNoMouse: boolean; {uses monochrome color schemes}
{methods}
constructor Init;
procedure SetLeft(On:boolean);
function LeftHanded:boolean;
function AdjustedButton(Button:integer):integer;
procedure SetForceOff(On:boolean);
procedure Reset;
function Installed:boolean;
procedure CheckInstalled;
procedure Show;
procedure Hide;
procedure Move(X,Y : integer);
procedure Confine(X1,Y1,X2,Y2:integer);
function Released(Button: integer; var X,Y: byte): byte;
function Pressed(Button: integer; var X,Y: byte): byte;
function InZone(X1,Y1,X2,Y2: byte):boolean;
procedure Location(var X,Y : byte);
procedure Status(var L,C,R:boolean; var X,Y : byte);
procedure WaitForRelease;
function Visible: boolean;
procedure SetMouseCursorStyle(OrdChar,Attr:byte);
function GetButtons: byte;
destructor Done;
end; {MouseOBJ}
pKeyOBJ = ^KeyOBJ;
KeyOBJ = object
vMouseMethod: byte; {0-no mouse, 1-cursor emulation, 2-freefloating mouse}
vBuffer: array[1..StuffBufferSize] of word;
vBufferHead: word; {next character from buffer}
vBufferTail:word; {last valid character in buffer}
vLastkey: word; {the last key pressed}
vLastX:byte; {location of mouse when button pressed}
vLastY:byte; { -"- }
vClick: boolean; {click after every keypress?}
vHorizSensitivity: byte; {no of characters}
vVertSensitivity: byte; { -"- }
vWaitForDouble: boolean;
vIdleHook: InputIdleProc;
vPressedHook: InputPressedProc;
vExtended : boolean; {is it an extended keyboard}
vButtons : byte;
vSlowdelay: integer; {time to wait for double click}
vLastPress: longint;
{methods...}
constructor Init;
procedure SetSlowDelay(Del:integer);
procedure AssignIdleHook(PassedProc: InputIdleProc);
procedure AssignPressedHook(PassedProc: InputPressedProc);
function Extended: boolean;
procedure SetCaps(On:boolean);
procedure SetNum(On:boolean);
procedure SetScroll(On:boolean);
function GetCaps:boolean;
function GetNum:boolean;
function GetScroll:boolean;
procedure SetRepeatRate(Delay,Rate:byte);
procedure SetFast;
procedure SetSlow;
procedure SetMouseMethod(Method:byte);
procedure SetClick(On: boolean);
procedure SetDouble(On:boolean);
function GetDouble:boolean;
procedure Click;
procedure SetHoriz(Sensitivity:byte);
procedure SetVert(Sensitivity:byte);
procedure GetInput;
function LastKey: word;
function LastChar: char;
function LastX: byte;
function LastY: byte;
function ExtendedKey(var K:byte):boolean;
function ReadKey: char;
function GetKey: word;
procedure FlushBuffer;
procedure StuffBuffer(W:word);
procedure StuffBufferStr(Str:string);
function Keypressed: boolean;
procedure DelayKey(Mills:longint);
function AltPressed:boolean;
function CtrlPressed:boolean;
function LeftShiftPressed: boolean;
function RightShiftPressed: boolean;
function ShiftPressed: boolean;
destructor Done;
end; {KeyOBJ}
procedure NoInputIdleHook;
procedure NoInputPressedHook(var W:word);
function Altkey(K: word): word;
procedure inputINIT;
VAR
AlphabetTOT: ^AlphabetOBJ;
Mouse: MouseOBJ;
Key: KeyOBJ;
IMPLEMENTATION
var
KeyStatusBits : ^word; {1.10}
{|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
{ }
{ U N I T P R O C E D U R E S & F U N C T I O N S }
{ }
{|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
{$F+}
procedure NoInputIdleHook;
{empty procs}
begin end; {NoInputIdleHook}
procedure NoInputPressedHook(var W:word);
{empty procs}
begin end; {NoInputPressedHook}
function EnglishUpCase(Ch:char):char;
{}
begin
EnglishUpCase := upcase(Ch);
end; {EnglishUpCase}
(*
inline($58/$3C/$61/$72/$39/$3C/$7A/$76/$33/$3C/$84/$75/$02/$B0/$8E
/$3C/$94/$75/$02/$B0/$99/$3C/$81/$75/$02/$B0/$9A
/$3C/$87/$75/$02/$B0/$80/$3C/$86/$75/$02/$B0/$BF
/$3C/$82/$75/$02/$B0/$90/$3C/$91/$75/$02/$B0/$92
/$3C/$A4/$75/$02/$B0/$A5/$EB/03/90/$2C/$20);
*)
function EnglishLoCase(Ch:char):char;
{}
begin
if Ch in ['A'..'Z'] then
EnglishLoCase := chr(ord(Ch) + 32)
else
EnglishLoCase := Ch;
end; {EnglishLoCase}
(*
inline($58/$3C/$41/$72/$39/$3C/$5A/$76/$33/$3C/$8E/$75/$02/$B0/$B4
/$3C/$99/$75/$02/$B0/$94/$3C/$9A/$75/$02/$B0/$81
/$3C/$8D/$75/$02/$B0/$87/$3C/$8F/$75/$02/$B0/$86
/$3C/$9D/$75/$02/$B0/$82/$3C/$92/$75/$02/$B0/$91
/$3C/$A5/$75/$02/$B0/$A4/$EB/03/90/$04/$20);
*)
{$F-}
function Altkey(K: word): word;
{returns the Alt keycode equivalent of a number or letter}
var AK: word;
begin
Case K of
65:AK:=286; 66:AK:=304; 67:AK:=302; 68:AK:=288; 69:AK:=274; 70:AK:=289;
71:AK:=290; 72:AK:=291; 73:AK:=279; 74:AK:=292; 75:AK:=293; 76:AK:=294;
77:AK:=306; 78:AK:=305; 79:AK:=280; 80:AK:=281; 81:AK:=272; 82:AK:=275;
83:AK:=287; 84:AK:=276; 85:AK:=278; 86:AK:=303; 87:AK:=273; 88:AK:=301;
89:AK:=277; 90:AK:=300; 48:AK:=385;
else if (K >= 49) and (K <= 57) then
AK := K + 327
else
AK